<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Festival/content')}">所有节日详情</a></li>
        <li class="active"><a href="{:url('Festival/addContent')}">添加内容</a></li>
    </ul>
    <div class="row margin-top-20">
        <div class="col-md-6">
            <form class="js-ajax-form" action="{:url('Festival/editContentPost')}" method="post">
                <div class="tab-content">
                    <div class="tab-pane active">
                        <div class="form-group">
                            <label for="input-parent"><span class="form-required">*</span>分类</label>
                            <div>
                                <input class="form-control" type="text" style="width:400px;" required value="{$festival['name']}"
                                   placeholder="请选择分类" onclick="doSelectCategory();" id="js-categories-name-input"
                                   readonly/>
                            	<input class="form-control" type="hidden" value="{$festival['id']}" name="fid"
                                   id="js-categories-id-input"/>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label for="input-description">图1</label>
                            <div>
                                <input type="hidden" name="image1" class="form-control"
                                       id="js-thumbnail-input" value="{$data['image1']}">
                                <div>
                                    <a href="javascript:uploadOneImage('图片上传','#js-thumbnail-input');">
                                        <if condition="empty($data['image1'])">
                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                 id="js-thumbnail-input-preview"
                                                 width="135" style="cursor: pointer"/>
                                            <else/>
                                            <img src="{:cmf_get_image_preview_url($data['image1'])}"
                                                 id="js-thumbnail-input-preview"
                                            width="135" style="cursor: pointer"/>
                                        </if>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-description">图2</label>
                            <div>
                                <input type="hidden" name="image2" class="form-control"
                                       id="js-thumbnail2-input" value="{$data['image2']}">
                                <div>
                                    <a href="javascript:uploadOneImage('图片上传','#js-thumbnail2-input');">
                                        <if condition="empty($data['image2'])">
                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                 id="js-thumbnail2-input-preview"
                                                 width="135" style="cursor: pointer"/>
                                            <else/>
                                            <img src="{:cmf_get_image_preview_url($data['image2'])}"
                                                 id="js-thumbnail2-input-preview"
                                            width="135" style="cursor: pointer"/>
                                        </if>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-description">图3</label>
                            <div>
                                <input type="hidden" name="image3" class="form-control"
                                       id="js-thumbnail3-input" value="{$data['image3']}">
                                <div>
                                    <a href="javascript:uploadOneImage('图片上传','#js-thumbnail3-input');">
                                        <if condition="empty($data['image3'])">
                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                 id="js-thumbnail3-input-preview"
                                                 width="135" style="cursor: pointer"/>
                                            <else/>
                                            <img src="{:cmf_get_image_preview_url($data['image3'])}"
                                                 id="js-thumbnail3-input-preview"
                                            width="135" style="cursor: pointer"/>
                                        </if>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-description">图4</label>
                            <div>
                                <input type="hidden" name="image4" class="form-control"
                                       id="js-thumbnail4-input" value="{$data['image4']}">
                                <div>
                                    <a href="javascript:uploadOneImage('图片上传','#js-thumbnail4-input');">
                                        <if condition="empty($data['image4'])">
                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                 id="js-thumbnail4-input-preview"
                                                 width="135" style="cursor: pointer"/>
                                            <else/>
                                            <img src="{:cmf_get_image_preview_url($data['image4'])}"
                                                 id="js-thumbnail4-input-preview"
                                            width="135" style="cursor: pointer"/>
                                        </if>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-description">图5</label>
                            <div>
                                <input type="hidden" name="image5" class="form-control"
                                       id="js-thumbnail5-input" value="{$data['image5']}">
                                <div>
                                    <a href="javascript:uploadOneImage('图片上传','#js-thumbnail5-input');">
                                        <if condition="empty($data['image5'])">
                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                 id="js-thumbnail5-input-preview"
                                                 width="135" style="cursor: pointer"/>
                                            <else/>
                                            <img src="{:cmf_get_image_preview_url($data['image5'])}"
                                                 id="js-thumbnail5-input-preview"
                                            width="135" style="cursor: pointer"/>
                                        </if>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-description">图6</label>
                            <div>
                                <input type="hidden" name="image6" class="form-control"
                                       id="js-thumbnail6-input" value="{$data['image6']}">
                                <div>
                                    <a href="javascript:uploadOneImage('图片上传','#js-thumbnail6-input');">
                                        <if condition="empty($data['image6'])">
                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                 id="js-thumbnail6-input-preview"
                                                 width="135" style="cursor: pointer"/>
                                            <else/>
                                            <img src="{:cmf_get_image_preview_url($data['image6'])}"
                                                 id="js-thumbnail6-input-preview"
                                            width="135" style="cursor: pointer"/>
                                        </if>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                	<input type="hidden" name="id" value="{$data['id']}">
                    <button type="submit" class="btn btn-primary js-ajax-submit" data-refresh="0">{:lang('SAVE')}</button>
                    <a class="btn btn-default" href="{:url('Festival/content')}">{:lang('BACK')}</a>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
function doSelectCategory() {
    var selectedCategoriesId = $('#js-categories-id-input').val();
    openIframeLayer("{:url('Festival/select')}?ids=" + selectedCategoriesId, '请选择分类', {
        area: ['700px', '400px'],
        btn: ['确定', '取消'],
        yes: function (index, layero) {
            //do something

            var iframeWin          = window[layero.find('iframe')[0]['name']];
            var selectedCategories = iframeWin.confirm();
            if (selectedCategories.selectedCategoriesId.length == 0) {
                layer.msg('请选择分类');
                return;
            }
            console.log(selectedCategories);
            $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
            $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
            layer.close(index); //如果设定了yes回调，需进行手工关闭
        }
    });
}
</script>
</body>
</html>